<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>用户管理</title>
    <link rel="stylesheet" href="{$Assets}layui/css/layui.css">
    <style type="text/css">
.layui-table-body{
    overflow: hidden;
}
    </style>
</head>
<body>
{include file="public/header" /}


<div style="width: 98%;margin:0 auto;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>会员列表</legend>
</fieldset>
<div class="demoTable">
    <button class="layui-btn layui-btn-normal" data-type="sync">同步积分</button>
</div>

<table class="layui-table" lay-data="{ url:'userall', page:true,limit:{$config_limit},limits:{$config_limits}, id:'user'}" lay-filter="demo">
    <thead>
    <tr>
        <th lay-data="{field:'id', width:100, sort: true,}">ID</th>
        <th lay-data="{field:'wxname'}">用户名</th>
        <th lay-data="{field:'telphone',width:180}">电话</th>
        <th lay-data="{field:'integral', width:130}">积分</th>
        <th lay-data="{field:'area', width:130}">地区</th>
        <th lay-data="{field:'addtime',width:180}">加入时间</th>
        <th lay-data="{field:'logintime',width:180}">最近登录</th>
        <th lay-data="{width:200, align:'center', toolbar: '#barDemo'}">积分操作</th>
 
    </tr>
    </thead>
</table>
</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="add">增加</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="reduce">减少</a>
</script>



<script src="{$Assets}layui/layui.js?t=1515376178709"></script>

<script>
    layui.use(['form', 'layedit', 'laydate','table'], function(){
  var table = layui.table,
      form = layui.form,
      $ = layui.jquery,
      layer = layui.layer,
      layedit = layui.layedit,
      laydate = layui.laydate;
        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });

         //监听工具条
          table.on('tool(demo)', function(obj){
                var data = obj.data;
                if(obj.event === 'add'){

                    layer.open({
                        type: 2
                        ,title: false //不显示标题栏
                        ,closeBtn: false
                        ,area: ['500px','365px']
                        ,shade: 0.8
                        ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
                        ,btnAlign: 'c'
                        ,closeBtn:2
                        ,moveType: 1 //拖拽模式，0或者1
                        ,content: '{:url("user/active")}?id='+data.id+'&&type=1'
                        ,end: function () {
                            location.reload();
                        }
                    });

                } else if(obj.event === 'reduce'){

                    layer.open({
                        type: 2
                        ,title: false //不显示标题栏
                        ,closeBtn: false
                        ,area: ['500px','365px']
                        ,shade: 0.8
                        ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
                        ,btnAlign: 'c'
                        ,closeBtn:2
                        ,moveType: 1 //拖拽模式，0或者1
                        ,content: '{:url("user/active")}?id='+data.id+'&&type=2'
                        ,end: function () {
                            location.reload();
                        }
                    });

                }
          });

         var $ = layui.$, active = {
            sync: function(){

                  $.ajax({
                        type:"POST",
                        url: "sync",
                        //data:{data:adddata},
                        dataType:"json",

                        success:function(datas){
                            if(datas==1){
                                layer.msg('同步成功！');
                                setTimeout(function(){
                                    self.location='/index.php/admin/user/user.html';
                                },1000);
                            }
                        }
                    });

            }
          };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
{include file="public/footer" /}


</body>
</html>
